<template>
  <div class="method-box">
    <h6 class="w-40">工程方法2:</h6>
    <el-form ref="formRef" :model="form" label-width="auto" :rules="rules">
      <div>
        <div>评分点计算公式：有效供应商价格分的计算：</div>
        <div class="flex gap-1">
          （1）有效投标报价等于评标基准价的，报价得分=
          <el-form-item prop="scoreP">
            <el-input
              v-model.number="form.scoreP"
              :disabled="disabled"
              class="text-input"
              size="small"
              clearable
              type="number"
              placeholder="P"
              @change="reflectChange"
            />
          </el-form-item>
          分。
        </div>
        <div class="flex gap-1">
          （2）如果投标人的有效投标报价＞评标基准价，则报价得分=P﹣|偏差率|×100×
          <el-form-item prop="scoreE1">
            <el-input
              v-model.number="form.scoreE1"
              :disabled="disabled"
              class="text-input"
              size="small"
              clearable
              type="number"
              placeholder="E1"
              @change="reflectChange"
            />
          </el-form-item>
          ；
        </div>
        <div class="flex gap-1">
          （3）如果投标人的有效投标报价≤评标基准价，则报价得分=P﹣|偏差率|×100×
          <el-form-item prop="scoreE2">
            <el-input
              v-model.number="form.scoreE2"
              :disabled="disabled"
              class="text-input"
              size="small"
              clearable
              type="number"
              placeholder="E2"
              @change="reflectChange"
            />
          </el-form-item>
          ；
        </div>
        <div>其中：E1是投标报价每高于评标基准价一个百分点的扣分值；E2是投标报价每低于评标基准价一个百分点的扣分值</div>
        <div class="flex gap-1">偏差率=100%×（评标基准价-投标人有效投标报价）/评标基准价</div>
        <div class="flex gap-1 flex-wrap">
          评标基准价=
          <el-form-item prop="scoreA">
            <el-input
              v-model.number="form.scoreA"
              :disabled="true"
              class="text-input"
              size="small"
              clearable
              type="number"
              placeholder="A"
              @change="reflectChange"
            />
          </el-form-item>
          ×
          <el-form-item prop="scoreK1">
            <el-input
              v-model.number="form.scoreK1"
              :disabled="disabled"
              class="text-input"
              size="small"
              clearable
              type="number"
              placeholder="K1"
              @change="reflectChange"
            >
              <template #suffix>%</template>
            </el-input>
          </el-form-item>
          % ×
          <el-form-item prop="scoreQ1">
            <el-input
              v-model.number="form.scoreQ1"
              :disabled="disabled"
              class="text-input"
              size="small"
              clearable
              type="number"
              placeholder="Q1"
              @change="reflectChange"
            >
              <template #suffix>%</template>
            </el-input>
          </el-form-item>
          +
          <el-form-item prop="scoreB">
            <el-input
              v-model.number="form.scoreB"
              :disabled="disabled"
              class="text-input"
              size="small"
              clearable
              type="number"
              placeholder="B"
              @change="reflectChange"
            />
          </el-form-item>
          ×
          <el-form-item prop="scoreQ2">
            <el-input
              v-model.number="form.scoreQ2"
              :disabled="true"
              class="text-input"
              size="small"
              clearable
              type="number"
              placeholder="Q2"
              @change="reflectChange"
            />
          </el-form-item>
          ×
          <el-form-item prop="scoreK2">
            <el-input
              v-model.number="form.scoreK2"
              :disabled="disabled"
              class="text-input"
              size="small"
              clearable
              type="number"
              placeholder="K2"
              @change="reflectChange"
            >
              <template #suffix>%</template>
            </el-input>
          </el-form-item>
          （A自动计算后自动填入，K1输入‘%’，Q1输入‘%’，Q2=1-Q1，K2输入‘%’）
        </div>
        <div class="flex gap-1">
          {{ ENGINEERING_METHOD }}
        </div>
      </div>
    </el-form>
  </div>
</template>
<script setup lang="ts">
import { ENGINEERING_METHOD } from '../data'
const emit = defineEmits(['value-change'])
const reflectChange = () => {
  emit('value-change')
}
const props = defineProps({
  formData: {
    type: Object,
    required: true
  },
  disabled: {
    type: Boolean,
    default: false
  }
})
const init = () => {
  form.value = props.formData
}
onMounted(() => {
  init()
})
const rules = ref<any>({
  scoreP: [{ required: true, message: '请输入scoreP' }],
  scoreE1: [{ required: true, message: '请输入scoreE1' }],
  scoreE2: [{ required: true, message: '请输入scoreE2' }],
  scoreK1: [{ required: true, message: '请输入scoreK1' }],
  scoreQ1: [{ required: true, message: '请输入scoreQ1' }],
  scoreB: [{ required: true, message: '请输入scoreB' }],
  scoreK2: [{ required: true, message: '请输入scoreK2' }]
})
const formRef = ref()
const submitForm = async () => {
  const res = await formRef.value.validate()
  return res
}
const form = ref<any>({
  scoreP: '',
  scoreE1: '',
  scoreE2: '',
  scoreA: '',
  scoreK1: '',
  scoreQ1: '',
  scoreB: '',
  scoreQ2: '',
  scoreK2: ''
})
defineExpose({ form, submitForm })
</script>
<style scoped lang="scss" src="./text-common.scss"></style>
